As published in Readout October 2003

SERIAL L.C.D. CONTROL

Dear EPE,

Since starting to program PICs back in 1998,
Ive developed a habit of writing my code in
reusable modules, the first of which is for a Stan-
dard alphanumeric (HD44780) lcd. display
controller module. It currently supports 4-bit
mode and 2-wire serial mode.

Serial mode involves connecting a 74LS164
or 74HC164 parallel output shift register, a
1N4148 diode and a 10k resistor. It uses two I/O
lines (shift reg data, shift reg clock and lcd. E-
line). Basically, a data nibble is loaded into the
shift register (bits 5 to 2), bit 6 is the RS bit and
bit 7 is used to gate the lcds E-line
(enable/clock). After a data byte has been loaded
(with reg pin 13 high), the diode and resistor act
like an AND gate.

If reg pin 13 is low, l.c.d. pin E is pulled low
through the diode. If reg pins 1, 2 and 13 are
high, E is high and the l.c.d. clocks in the data
nibble.

The connections required are:

	-	74xx164	LCD.
	PlC RB7	1 and 2	E, via 10k resistor
	PICRB6	8	-
	-	5	D4
	-	6	D5
	-	10	D6
	-	11	D7
	-	12	RS
	-	13	E, via 1N4148 diode *
	Vcc	9 and 14	Vcc
	Vss	7	Vss

*Connect the 1N4148s cathode to 74xx164
pin 13, and its anode to lcd. pin E (which also
has the 10k resistor connected to it).

I could have used a CMOS or TTL AND gate,
but that would have unnecessarily increased the
chip count and a diode/resistor AND gate works
just as well.

Run MPASM to compile one of the test files,
program into a P1C16F874 (or P1C16F877),
connect up an lcd. and power up. Ive tested the
code on a P1C16F84 and a P1C16F628 as well.
But the standard disclaimer applies  it works
for me, your mileage may vary.

I have to say that a 16 x 1 lcd. connected
over a two-wire interface is one of the most use-
ful PlC code debugging tools Ive got.

Philip Pemberton, via email

That seems nice and simple Philip, and very
useful, thank you. The test files you refer to have
been put into the PlC Tricks folder on our ftp
site.
